package org.codeart.flyweight.demo1;

public class Client {

    public static void main(String[] args) {
        FlyweightFactory factory = new FlyweightFactory();
        
        // 通过工厂对象获取共享的享元对象
        FlyWeight f1 = factory.getFlyWeight("A");
        f1.operate("f1 external");
        
        FlyWeight f2 = factory.getFlyWeight("A");
        f2.operate("f2 external");
        System.out.println(f1 == f2);
        
        // 获取非共享的享元对象
        FlyWeight f3 = new UnsharedFlyweight("A");
        FlyWeight f4 = new UnsharedFlyweight("A");
        System.out.println(f3 == f4);
    }

}
